package com.ymm.lulutong.domain;

import com.ymm.lulutong.entity.Wallet;
import com.ymm.lulutong.entity.WalletOpsLog;
import com.ymm.lulutong.utils.Result;

import java.util.List;

/**
 * @author guorui
 */
public interface ShipperWalletDomainService {
    /**
     * 获取钱包
     *
     * @param shipperId 货主id
     * @return 余额
     */
    Result<Wallet> getWalletByShipperId(Long shipperId);

    /**
     * 充值
     *
     * @param shipperId  货主Id
     * @param topUpMoney 充值金额
     * @return 日志Id
     */
    Result<Long> topUp(Long shipperId, Integer topUpMoney) throws Exception;

    /**
     * 返现
     *
     * @param shipperId     货主Id
     * @param cashBackMoney 返现金额
     * @return 日志Id
     */
    Result<Long> cashBack(Long shipperId, Integer cashBackMoney, Long cargoId, Long orderId) throws Exception;

    /**
     * 退款
     *
     * @param shipperId   货主Id
     * @param refundMoney 退款金额
     * @param orderId 关联的订单Id，可以为空
     * @return 日志Id
     */
    Result<Long> refund(Long shipperId, Integer refundMoney, Long cargoId, Long orderId) throws Exception;

    /**
     * 支付
     *
     * @param shipperId 货主Id
     * @param payMoney  支付金额
     * @return 日志Id
     */
    Result<Long> pay(Long shipperId, Integer payMoney) throws Exception;

    /**
     * 提现
     *
     * @param shipperId       货主Id
     * @param withdrawalMoney 提现金额
     * @return 日志Id
     */
    Result<Long> withdrawal(Long shipperId, Integer withdrawalMoney) throws Exception;

    /**
     * 获取货主账单
     *
     * @param shipperId 货主Id
     * @return 货主钱包操作记录
     */
    Result<List<WalletOpsLog>> getRunningAccountByShipperId(Long shipperId);


    /**
     * 根据条件更新一条记录
     *
     * @param walletOpsLog 记录
     * @return 日志Id
     * @throws Exception 异常
     */
    Result<Long> updateLogByLogIdOnCondition(WalletOpsLog walletOpsLog) throws Exception;

    /**
     * 为发货付款
     * @param shipperId 货主Id
     * @param payMoney 付款金额
     * @param cargoId 货源Id
     * @return 日志Id
     */
    Result<Long> payForCargo(Long shipperId, Integer payMoney, Long cargoId) throws Exception;
}
